<template>
    <view>
        <view v-if="detail != null">
			<view class="hongbao_top">
				<image class="" :src="groups_static_url+'mini/hongbaosee.png'" mode="widthFix" />
			</view>
			<view class="padding-horizontal-main padding-top-main">
				<view class="hongbao_send_people">
					<image class="icon auto dis-inline-block" :src="home_site_logo_square" mode="widthFix"></image>
					<text class="dis-inline-block">{{lang_info.groups_hongbao_tips_title}}</text>
				</view>
				<view class="hongbao_miaoshu tc">
					<view class="">{{lang_info.groups_hongbao_buchang_tips_msg}}</view>
				</view>
				<view class="hongbao_jiage tc">
					<text class="t1">{{detail.hongbao}}</text>
					<text class="t2">{{currency_symbol_after}}</text>
				</view>
				<view class="hongbao_qianbao arrow-right tc" @tap="url_event" data-value="/pages/plugins/wallet/user/user">
					<text class="t1">{{lang_info.groups_hongbao_buchang__wallet_tips_msg}}</text>
				</view>
			</view>
        </view>

        <view v-if="detail == null">
            <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
        </view>
    </view>
</template>

<script>
import componentNoData from "@/components/no-data/no-data";
const app = getApp();
import { groups_base_info, clear_user_cach } from '@/pages/fcc/groups/public/common.js';

var groups_static_url = app.globalData.get_static_url('groups', true);
var common_static_url = app.globalData.get_static_url('common');
export default {
	components: {
		componentNoData
	},
    data() {
        return {
            currency_symbol_after: app.globalData.currency_symbol(),
			groups_static_url: groups_static_url,
			common_static_url: common_static_url,
            params: null,
            data_list_loding_status: 1,
            data_list_loding_msg:'',
            data_bottom_line_status: false,
            detail: null,
			home_site_logo_square:null,
			// 多语言
			lang_info:{},
        };
    },
    onLoad(params) {
        this.setData({
            params: params
        });
    },
    onShow() {
		this.init_config();
		this.init();
    },
    // 下拉刷新
    onPullDownRefresh() {
        this.init();
    },
    methods: {
		// 初始化配置
		init_config(status) {
		    if ((status || false) == true) {
		        this.setData({
		            home_site_logo_square: app.globalData.get_config('config.home_site_logo_square'),
		        });
		    } else {
		        app.globalData.is_config(this, 'init_config');
		    }
		},
		
        // 获取数据列表
        init() {
        	// 先获取语言基础信息
        	groups_base_info()
        	.then(data=>{
        		this.init_before(data)
        		.then(()=>{
        			this.init_real();
        		});
        	});
        },
        
        // 设置本页参数
        init_before(data){
        	var self = this;
        	return new Promise((resolve, reject) => {
        		self.setData({
        			lang_info:data,
        		});
				uni.setNavigationBarTitle({
				    title: data.groups_hongbao_title
				});
        		resolve();
        	});
        },
        
        // 真正的数据初始化
        init_real(){
            var self = this;
            uni.showLoading({
                title: this.lang_info.loading_tips
            });
            this.setData({
                data_list_loding_status: 1
            });
            uni.request({
                url: app.globalData.get_request_url('OrderDetail', 'index', 'groups'),
                method: 'POST',
                data: {
                    id: this.params.id
                },
                dataType: 'json',
                success: (res) => {console.log(res);
                    uni.hideLoading();
                    uni.stopPullDownRefresh();

                    if (res.data.code == 0) {
                        var data = res.data.data;
                        self.setData({
                            detail: data.data,
                            data_list_loding_status: 3,
                            data_bottom_line_status: true,
                            data_list_loding_msg: ''
                        });
                    } else {
                        self.setData({
                            data_list_loding_status: 2,
                            data_bottom_line_status: false,
                            data_list_loding_msg: res.data.msg
                        });

                        if (app.globalData.is_login_check(res.data, self, 'init')) {
                            app.globalData.showToast(res.data.msg);
                        }
                    }
                },
                fail: () => {
                    uni.hideLoading();
                    uni.stopPullDownRefresh();
                    self.setData({
                        data_list_loding_status: 2,
                        data_bottom_line_status: false,
                        data_list_loding_msg: self.lang_info.request_data_error_tips
                    });
                    app.globalData.showToast(self.lang_info.request_data_error_tips);
                }
            });
        },
		
		// url事件
		url_event(e) {
		    app.globalData.url_event(e);
		}
    }
};
</script>
<style>
@import './hongbao.css';
</style>
